from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional, List
from decimal import Decimal
from datetime import date


# 广告
class AdvertBase(BaseModel):
    weid: Optional[int] = Field(0, ge=0, description="站点 ID")
    homeId: Optional[str] = Field(None, max_length=255, description="首页广告id")
    secondId: Optional[str] = Field(None, max_length=255, description="解析页广告id")
    createtime: Optional[int] = Field(None, description="创建时间，Unix 时间戳")

    class Config:
        orm_mode = True


class AdvertCreate(AdvertBase):
    pass


class AdvertUpdate(AdvertBase):
    weid: Optional[int] = None
    homeId: Optional[str] = None
    secondId: Optional[str] = None
    createtime: Optional[int] = None


class AdvertInDB(AdvertBase):
    id: int
    createtime: Optional[datetime] = Field(None, description="创建时间")

    @classmethod
    def from_orm(cls, obj):
        if isinstance(obj.createtime, int) and obj.createtime is not None:
            obj.createtime = datetime.fromtimestamp(obj.createtime)
        return super().from_orm(obj)


class AdvertResponse(AdvertInDB):
    pass


class AdvertListResponse(BaseModel):
    data: List[AdvertResponse]


# 班级
class BanjiBase(BaseModel):
    weid: Optional[int] = None
    uidht: int
    school_id: int
    nianfen_id: int
    xdgl_id: int
    nid: int
    name: str
    bname: str
    parentid: int
    displayorder: int
    enabled: bool
    icon: str
    banjikouhao: str
    banxun: str
    banjimubiao: str
    bzrjy: str
    description: str
    styleid: int
    linkurl: str
    ishomepage: bool
    status: Optional[int] = 0
    icontype: bool
    css: str

    class Config:
        orm_mode = True


class BanjiCreate(BanjiBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class BanjiUpdate(BanjiBase):
    # 允许部分更新，所以所有字段都是可选的
    weid: Optional[int] = None
    uidht: Optional[int] = None
    school_id: Optional[int] = None
    nianfen_id: Optional[int] = None
    xdgl_id: Optional[int] = None
    nid: Optional[int] = None
    name: Optional[str] = None
    bname: Optional[str] = None
    parentid: Optional[int] = None
    displayorder: Optional[int] = None
    enabled: Optional[bool] = None
    icon: Optional[str] = None
    banjikouhao: Optional[str] = None
    banxun: Optional[str] = None
    banjimubiao: Optional[str] = None
    bzrjy: Optional[str] = None
    description: Optional[str] = None
    styleid: Optional[int] = None
    linkurl: Optional[str] = None
    ishomepage: Optional[bool] = None
    status: Optional[int] = None
    icontype: Optional[bool] = None
    css: Optional[str] = None


class BanjiInDB(BanjiBase):
    banji_id: int

    class Config:
        orm_mode = True


# 轮播图
class BannerBase(BaseModel):
    weid: int
    title: str = Field(..., max_length=255)
    image: str = Field(..., max_length=255, description="图片路径")
    type: Optional[int] = Field(1, ge=1, le=2, description="图片跳转方式 1本程序跳转 2外部链接")
    link: Optional[str] = None
    status: Optional[int] = Field(2, ge=1, le=2, description="图片状态 1 显示 2 不显示")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="是否删除的标识")

    class Config:
        orm_mode = True


class BannerCreate(BannerBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class BannerUpdate(BannerBase):
    weid: Optional[int] = None
    title: Optional[str] = None
    image: Optional[str] = None
    type: Optional[int] = None
    link: Optional[str] = None
    status: Optional[int] = None
    createtime: Optional[int] = None
    istatus: Optional[int] = None


class BannerInDB(BannerBase):
    id: int

    class Config:
        orm_mode = True


class BannerResponse(BannerInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class BannerListResponse(BaseModel):
    data: List[BannerResponse]


class CategoryBase(BaseModel):
    weid: int
    name: str = Field(..., max_length=255, description="分类名称")
    pid: Optional[str] = Field("0", max_length=255, description="分类父级，默认为顶级分类")
    order: Optional[int] = Field(0, ge=0, le=99999, description="分类序号，默认为0")
    status: Optional[int] = Field(1, ge=1, le=2, description="分类状态 1 显示 2 不显示")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="是否删除的标识")

    class Config:
        orm_mode = True


class CategoryCreate(CategoryBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class CategoryUpdate(CategoryBase):
    weid: Optional[int] = None
    name: Optional[str] = None
    pid: Optional[str] = None
    order: Optional[int] = None
    status: Optional[int] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None

    class Config:
        orm_mode = True


class CategoryInDB(CategoryBase):
    id: int

    createtime: int = Field(..., description="创建时间，Unix 时间戳")

    class Config:
        orm_mode = True


class CategoryResponse(CategoryInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class CategoryListResponse(BaseModel):
    data: List[CategoryResponse]


# 兑换码
class CdkeyBase(BaseModel):
    weid: int = Field(..., description="站点 ID")
    cid: int = Field(..., description="分类 ID")
    code: Optional[str] = Field(None, max_length=255, description="题库代码")
    uid: int = Field(0, ge=0, description="用户 ID，默认为0表示未领取")
    createtime: Optional[int] = Field(None, description="创建时间，Unix 时间戳")
    usetime: Optional[int] = Field(None, description="使用时间，Unix 时间戳")
    status: Optional[int] = Field(1, ge=1, le=2, description="状态 1未使用 2已使用")
    kpool: Optional[str] = Field(None, max_length=2000, description="到期时间或相关数据")
    display: int = Field(1, ge=1, le=2, description="启用状态 1启用 2作废")
    day_num: Optional[int] = Field(None, ge=0, description="激活天数")
    endtime: Optional[int] = Field(None, description="结束时间，Unix 时间戳")

    class Config:
        orm_mode = True


class CdkeyCreate(CdkeyBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class CdkeyUpdate(CdkeyBase):
    weid: Optional[int] = None
    cid: Optional[int] = None
    code: Optional[str] = None
    uid: Optional[int] = None
    createtime: Optional[int] = None
    usetime: Optional[int] = None
    status: Optional[int] = None
    kpool: Optional[str] = None
    display: Optional[int] = None
    day_num: Optional[int] = None
    endtime: Optional[int] = None


class CdkeyInDB(CdkeyBase):
    id: int

    class Config:
        orm_mode = True


class CdkeyResponse(CdkeyInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class CdkeyListResponse(BaseModel):
    data: List[CdkeyResponse]


class CdkeyCateBase(BaseModel):
    weid: int = Field(..., description="站点 ID")
    title: str = Field(..., max_length=255, description="分类标题")
    createtime: Optional[int] = Field(None, description="创建时间，Unix 时间戳")
    qpool: Optional[str] = Field(None, max_length=2000, description="题库")
    kpool: Optional[str] = Field(None, max_length=2000, description="知识库")
    msg: Optional[str] = Field(None, max_length=255, description="提示信息")
    status: Optional[int] = Field(1, ge=1, le=2, description="状态 1启用 2禁用")
    is_delete: Optional[int] = Field(1, ge=1, le=2, description="删除状态 1正常 2删除")
    papers: str = Field(..., max_length=2000, description="试卷 IDs")

    class Config:
        orm_mode = True


class CdkeyCateCreate(CdkeyCateBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class CdkeyCateUpdate(CdkeyCateBase):
    weid: Optional[int] = None
    title: Optional[str] = None
    createtime: Optional[int] = None
    qpool: Optional[str] = None
    kpool: Optional[str] = None
    msg: Optional[str] = None
    status: Optional[int] = None
    is_delete: Optional[int] = None
    papers: Optional[str] = None


class CdkeyCateInDB(CdkeyCateBase):
    id: int

    class Config:
        orm_mode = True


class CdkeyCateResponse(CdkeyCateInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class CdkeyCateListResponse(BaseModel):
    data: List[CdkeyCateResponse]


class CdkeysBase(BaseModel):
    weid: int = Field(..., description="站点 ID")
    code_id: int = Field(..., ge=0, description="兑换码 ID")
    kpool_id: int = Field(..., ge=0, description="绑定对象 ID（试卷或题库）")
    type: int = Field(0, ge=0, le=2, description="绑定类型 1 试卷 2 题库")

    class Config:
        orm_mode = True


class CdkeysCreate(CdkeysBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class CdkeysUpdate(CdkeysBase):
    weid: Optional[int] = None
    code_id: Optional[int] = None
    kpool_id: Optional[int] = None
    type: Optional[int] = None


class CdkeysInDB(CdkeysBase):
    id: int

    class Config:
        orm_mode = True


class CdkeysResponse(CdkeysInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class CdkeysListResponse(BaseModel):
    data: List[CdkeysResponse]


# 练习
class ExerciseBase(BaseModel):
    weid: Optional[int] = Field(0, ge=0, description="站点 ID，默认为0")
    uid: int = Field(..., ge=0, description="用户 ID")
    testid: int = Field(..., ge=0, description="测试题 ID")
    test_type: Optional[int] = Field(None, description="测试类型")
    uanswer: Optional[str] = Field(None, max_length=255, description="用户答案")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="状态 1有效 2无效")
    createtime: Optional[int] = Field(None, description="创建时间，Unix 时间戳")
    isright: int = Field(..., ge=0, le=1, description="是否正确 1正确 0错误")

    class Config:
        orm_mode = True


class ExerciseCreate(ExerciseBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class ExerciseUpdate(ExerciseBase):
    weid: Optional[int] = None
    uid: Optional[int] = None
    testid: Optional[int] = None
    test_type: Optional[int] = None
    uanswer: Optional[str] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None
    isright: Optional[int] = None


class ExerciseInDB(ExerciseBase):
    id: int

    class Config:
        orm_mode = True


class ExerciseResponse(ExerciseInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class ExerciseListResponse(BaseModel):
    data: List[ExerciseResponse]


class FeedbackBase(BaseModel):
    weid: Optional[int] = Field(0, ge=0, description="站点 ID，默认为0")
    uid: int = Field(..., ge=0, description="用户 ID")
    testid: Optional[int] = Field(None, ge=0, description="测试题 ID")
    relation: Optional[str] = Field(None, max_length=255, description="关联信息")
    content: Optional[str] = Field(None, description="反馈内容")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="状态 1有效 2无效")
    createtime: Optional[int] = Field(None, description="创建时间，Unix 时间戳")

    class Config:
        orm_mode = True


class FeedbackCreate(FeedbackBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class FeedbackUpdate(FeedbackBase):
    weid: Optional[int] = None
    uid: Optional[int] = None
    testid: Optional[int] = None
    relation: Optional[str] = None
    content: Optional[str] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None


class FeedbackInDB(FeedbackBase):
    id: int

    class Config:
        orm_mode = True


class FeedbackResponse(FeedbackInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class FeedbackListResponse(BaseModel):
    data: List[FeedbackResponse]


class GiftBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID，默认为0")
    name: str = Field(..., max_length=100, description="礼品名称")
    price: int = Field(100, ge=0, description="礼品市场价格，默认为100")
    coins: int = Field(500, ge=0, description="礼品所需金币，默认为500")
    image: str = Field(..., max_length=255, description="礼品图片路径")
    about: str = Field(..., description="礼品描述")

    class Config:
        orm_mode = True


class GiftCreate(GiftBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class GiftUpdate(GiftBase):
    weid: Optional[int] = None
    name: Optional[str] = None
    price: Optional[int] = None
    coins: Optional[int] = None
    image: Optional[str] = None
    about: Optional[str] = None


class GiftInDB(GiftBase):
    id: int

    class Config:
        orm_mode = True


class GiftResponse(GiftInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class GiftListResponse(BaseModel):
    data: List[GiftResponse]


class IndexBtnBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID，默认为0")
    doid: int = Field(..., ge=0, description="操作 ID，默认为0")
    title: str = Field(..., max_length=255, description="按钮标题")
    icon: Optional[str] = Field(None, max_length=255, description="图片路径")
    status: Optional[int] = Field(1, ge=1, le=2, description="显示状态 1 显示 2 不显示")
    sort: Optional[int] = Field(0, ge=0, description="排序，默认为0")
    types: int = Field(1, ge=1, le=2, description="类型 1模块功能 2题库")
    library_id: int = Field(..., ge=0, description="关联的题库或模块 ID")

    class Config:
        orm_mode = True


class IndexBtnCreate(IndexBtnBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class IndexBtnUpdate(IndexBtnBase):
    weid: Optional[int] = None
    doid: Optional[int] = None
    title: Optional[str] = None
    icon: Optional[str] = None
    status: Optional[int] = None
    sort: Optional[int] = None
    types: Optional[int] = None
    library_id: Optional[int] = None


class IndexBtnInDB(IndexBtnBase):
    id: int

    class Config:
        orm_mode = True


class IndexBtnResponse(IndexBtnInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class IndexBtnListResponse(BaseModel):
    data: List[IndexBtnResponse]


class KnowledgeBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    one: Optional[int] = Field(0, ge=0, description="一级分类，默认为0")
    two: Optional[int] = Field(0, ge=0, description="二级分类，默认为0")
    three: Optional[int] = Field(0, ge=0, description="三级分类，默认为0")
    title: str = Field(..., max_length=255, description="知识点标题")
    content: str = Field(..., description="知识点内容")
    status: Optional[int] = Field(2, ge=1, le=2, description="显示状态 1显示 2不显示，默认为2")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="删除标识 1正常 2删除，默认为1")

    class Config:
        orm_mode = True


class KnowledgeCreate(KnowledgeBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class KnowledgeUpdate(KnowledgeBase):
    weid: Optional[int] = None
    one: Optional[int] = None
    two: Optional[int] = None
    three: Optional[int] = None
    title: Optional[str] = None
    content: Optional[str] = None
    status: Optional[int] = None
    createtime: Optional[int] = None
    istatus: Optional[int] = None


class KnowledgeInDB(KnowledgeBase):
    id: int

    class Config:
        orm_mode = True


class KnowledgeResponse(KnowledgeInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class KnowledgeListResponse(BaseModel):
    data: List[KnowledgeResponse]


class KnowledgeCateBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    name: str = Field(..., max_length=255, description="知识点分类名称")
    type: Optional[int] = Field(1, ge=1, le=2, description="分类类型 1刷知识点 2考前必备，默认为1")
    pid: Optional[int] = Field(0, ge=0, description="父级分类 ID，默认为0表示顶级分类")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="删除标识 1正常 2删除，默认为1")
    status: Optional[int] = Field(1, ge=1, le=2, description="显示状态 1显示 2隐藏，默认为1")
    price: Decimal = Field(Decimal('0.00'), ge=0, description="价格，默认为0.00")
    create_time: int = Field(..., description="创建时间，Unix 时间戳")

    class Config:
        orm_mode = True


class KnowledgeCateCreate(KnowledgeCateBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class KnowledgeCateUpdate(KnowledgeCateBase):
    weid: Optional[int] = None
    name: Optional[str] = None
    type: Optional[int] = None
    pid: Optional[int] = None
    istatus: Optional[int] = None
    status: Optional[int] = None
    price: Optional[Decimal] = None
    create_time: Optional[int] = None


class KnowledgeCateInDB(KnowledgeCateBase):
    id: int

    class Config:
        orm_mode = True


class KnowledgeCateResponse(KnowledgeCateInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class KnowledgeCateListResponse(BaseModel):
    data: List[KnowledgeCateResponse]


class NoticeBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    type: int = Field(..., ge=1, le=2, description="公告类型，默认值需在数据库中明确")
    title: str = Field(..., max_length=255, description="公告标题")
    content: str = Field(..., description="公告内容")
    image: Optional[str] = Field(None, max_length=255, description="活动公告的图片路径")
    readnum: Optional[int] = Field(0, ge=0, description="阅读量，默认为0")
    status: Optional[int] = Field(2, ge=1, le=2, description="公告状态 1显示 2不显示，默认为2")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="删除标识 1正常 2删除，默认为1")
    video_audio_id: Optional[str] = Field(None, max_length=255, description="音/视频ID")
    pcate: Optional[int] = Field(None, ge=0, description="文章所属分类")
    ccate: Optional[int] = Field(None, ge=0, description="文章所属子分类")
    article_type: Optional[int] = Field(None, ge=1, le=2, description="文章类型 1文章 2视频")

    class Config:
        orm_mode = True


class NoticeCreate(NoticeBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class NoticeUpdate(NoticeBase):
    weid: Optional[int] = None
    type: Optional[int] = None
    title: Optional[str] = None
    content: Optional[str] = None
    image: Optional[str] = None
    readnum: Optional[int] = None
    status: Optional[int] = None
    createtime: Optional[int] = None
    istatus: Optional[int] = None
    video_audio_id: Optional[str] = None
    pcate: Optional[int] = None
    ccate: Optional[int] = None
    article_type: Optional[int] = None


class NoticeInDB(NoticeBase):
    id: int

    class Config:
        orm_mode = True


class NoticeResponse(NoticeInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class NoticeListResponse(BaseModel):
    data: List[NoticeResponse]


class OrderBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    type: int = Field(..., ge=1, le=2, description="购买类型 1购买考试 2VIP购买")
    out_trade_no: str = Field(..., max_length=255, description="订单号")
    userid: int = Field(..., ge=0, description="用户 ID")
    openid: Optional[str] = Field(None, max_length=255, description="购买者的 openid")
    order_status: int = Field(..., ge=0, le=1, description="订单状态 0未支付 1已支付")
    all_money: Decimal = Field(Decimal('0.00'), ge=0, description="总金额，默认为0.00")
    true_money: Decimal = Field(..., ge=0, description="实付款")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")
    paytime: Optional[int] = Field(None, description="支付时间，Unix 时间戳")
    msg: Optional[str] = Field(None, max_length=255, description="消息")
    dataid: Optional[int] = Field(None, ge=0, description="关联数据 ID")
    transaction_sn: Optional[str] = Field(None, max_length=255, description="第三方流水号")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="订单删除标识 1正常 2删除，默认为1")

    class Config:
        orm_mode = True


class OrderCreate(OrderBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class OrderUpdate(OrderBase):
    weid: Optional[int] = None
    type: Optional[int] = None
    out_trade_no: Optional[str] = None
    userid: Optional[int] = None
    openid: Optional[str] = None
    order_status: Optional[int] = None
    all_money: Optional[Decimal] = None
    true_money: Optional[Decimal] = None
    createtime: Optional[int] = None
    paytime: Optional[int] = None
    msg: Optional[str] = None
    dataid: Optional[int] = None
    transaction_sn: Optional[str] = None
    istatus: Optional[int] = None


class OrderInDB(OrderBase):
    id: int

    class Config:
        orm_mode = True


class OrderResponse(OrderInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class OrderListResponse(BaseModel):
    data: List[OrderResponse]


class PaperBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    title: str = Field(..., max_length=255, description="试卷标题")
    type: Optional[int] = Field(1, ge=1, le=3, description="试卷类型，默认为1")
    franction: str = Field(..., description="每个题型有多少及每个题多少分")
    total_franction: Optional[int] = Field(0, ge=0, description="试卷总分值，默认为0")
    status: Optional[int] = Field(2, ge=1, le=2, description="试卷状态 默认为2 待完善试卷 1 已完善试卷")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="是否删除的标识，默认为1")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")
    dnum: Optional[int] = Field(0, ge=0, description="做题人数，默认为0")
    displayorder: Optional[int] = Field(0, ge=0, description="显示顺序，默认为0")
    price: Decimal = Field(Decimal('0.00'), ge=0, description="试卷价格，默认为0.00")
    times: int = Field(..., ge=0, description="试卷时间单位分")
    is_repeat: int = Field(2, ge=1, le=2, description="重复答题 1可以 2否，默认为2")

    class Config:
        orm_mode = True


class PaperCreate(PaperBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class PaperUpdate(PaperBase):
    weid: Optional[int] = None
    title: Optional[str] = None
    type: Optional[int] = None
    franction: Optional[str] = None
    total_franction: Optional[int] = None
    status: Optional[int] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None
    dnum: Optional[int] = None
    displayorder: Optional[int] = None
    price: Optional[Decimal] = None
    times: Optional[int] = None
    is_repeat: Optional[int] = None


class PaperInDB(PaperBase):
    id: int

    class Config:
        orm_mode = True


class PaperResponse(PaperInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class PaperListResponse(BaseModel):
    data: List[PaperResponse]


class PaperTestBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    paperid: str = Field(..., max_length=255,
                         description="试卷 ID（注意：在表注释中提到的是试卷标题，但字段名为 paperid，通常应为试卷 ID）")
    testid: int = Field(..., ge=0, description="试题 ID")
    test_type: int = Field(..., ge=0, description="题型类型")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="是否删除的标识，默认为1")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")

    class Config:
        orm_mode = True


class PaperTestCreate(PaperTestBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class PaperTestUpdate(PaperTestBase):
    weid: Optional[int] = None
    paperid: Optional[str] = None
    testid: Optional[int] = None
    test_type: Optional[int] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None


class PaperTestInDB(PaperTestBase):
    id: int

    class Config:
        orm_mode = True


class PaperTestResponse(PaperTestInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class PaperTestListResponse(BaseModel):
    data: List[PaperTestResponse]


class PhoneCodeBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    phone: str = Field(..., min_length=11, max_length=11, regex=r"^\d{11}$", description="手机号码")
    code: int = Field(..., ge=100000, le=999999, description="手机验证码，通常为6位数字")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")

    class Config:
        orm_mode = True


class PhoneCodeCreate(PhoneCodeBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class PhoneCodeUpdate(PhoneCodeBase):
    weid: Optional[int] = None
    phone: Optional[str] = None
    code: Optional[int] = None
    createtime: Optional[int] = None


class PhoneCodeInDB(PhoneCodeBase):
    id: int

    class Config:
        orm_mode = True


class PhoneCodeResponse(PhoneCodeInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class PhoneCodeListResponse(BaseModel):
    data: List[PhoneCodeResponse]


class QYearBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    name: str = Field(..., max_length=255, description="年份名称")
    status: Optional[int] = Field(1, ge=1, le=2, description="状态 1 显示 2不显示，默认为1")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="是否删除的标识，默认为1")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")

    class Config:
        orm_mode = True


class QYearCreate(QYearBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class QYearUpdate(QYearBase):
    weid: Optional[int] = None
    name: Optional[str] = None
    status: Optional[int] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None


class QYearInDB(QYearBase):
    id: int

    class Config:
        orm_mode = True


class QYearResponse(QYearInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class QYearListResponse(BaseModel):
    data: List[QYearResponse]


class SchoolBase(BaseModel):
    weid: Optional[int] = Field(None, ge=0, description="站点 ID")
    school_name: Optional[str] = Field(None, max_length=200, description="学校名称")
    school_logo: Optional[str] = Field(None, max_length=200, description="学校 Logo URL")
    school_info_intro: Optional[str] = Field(None, description="学校描述")
    addtime: Optional[int] = Field(None, description="添加时间，Unix 时间戳")
    mu_str: Optional[str] = Field(None, max_length=30, description="未知字段（mu_str）")
    status: Optional[int] = Field(1, ge=1, le=2, description="状态，默认为1")
    line_status: Optional[int] = Field(1, ge=1, le=2, description="线路状态，默认为1")
    cookbook_status: Optional[int] = Field(1, ge=1, le=2, description="食谱状态，默认为1")
    class_notice_status: Optional[int] = Field(1, ge=1, le=2, description="班级公告审核状态；1=不需要；2=需要，默认为1")
    school_type: Optional[int] = Field(0, ge=0, description="学校类型，默认为0")
    host_url: Optional[str] = Field(None, description="官网地址")
    on_school: Optional[int] = Field(0, ge=0, description="在校天数，默认为0")
    begin_day: Optional[int] = Field(0, ge=0, description="开始上课周数，默认为0")
    am_much: Optional[int] = Field(0, ge=0, description="上午课数，默认为0")
    pm_much: Optional[int] = Field(0, ge=0, description="下午课数，默认为0")
    ye_much: Optional[int] = Field(0, ge=0, description="晚上课数，默认为0")
    line_type: Optional[str] = Field(None, description="班级圈类别")
    appointment: Optional[str] = Field(None, description="预约类别")
    parents: Optional[int] = Field(3, ge=0, description="学生可绑定家长数，默认为3")
    add_time: Optional[int] = Field(0, ge=0, description="添加时间，默认为0")

    class Config:
        orm_mode = True


class SchoolCreate(SchoolBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class SchoolUpdate(SchoolBase):
    school_id: Optional[int] = None  # 允许更新时指定学校 ID


class SchoolInDB(SchoolBase):
    school_id: int

    class Config:
        orm_mode = True


class SchoolResponse(SchoolInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class SchoolListResponse(BaseModel):
    data: List[SchoolResponse]


class SettingBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    mchid: Optional[str] = Field(None, max_length=50, description="微信支付商户ID")
    pay_secret: Optional[str] = Field(None, max_length=50, description="支付密匙")
    pay_open: Optional[int] = Field(0, ge=0, le=1, description="支付开启 1开启")
    signcertpath: Optional[str] = Field(None, max_length=255, description="商户CERT证书路径")
    signkeypath: Optional[str] = Field(None, max_length=255, description="商户KEY证书路径")
    AccessKeyId: Optional[str] = Field(None, max_length=255, description="阿里云账号")
    AccessKeySecret: Optional[str] = Field(None, max_length=255, description="阿里云秘钥")
    SignName: Optional[str] = Field(None, max_length=255, description="阿里云短信签名")
    TemplateCode: Optional[str] = Field(None, max_length=255, description="阿里云验证码模板id")
    RegionId: Optional[str] = Field(None, max_length=255, description="阿里云视频点播区域名")
    banner_height: Optional[int] = Field(232, ge=0, description="轮播图高")
    shareupper: Optional[int] = Field(0, ge=0, description="每日分享获得积分上限")
    share_title: Optional[str] = Field(None, max_length=255, description="分享标题")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="是否删除的标识，默认为1")
    is_display: Optional[int] = Field(1, ge=1, le=2, description="公告是否显示，默认为1")
    display_num: Optional[int] = Field(5, ge=0, description="公告显示条数，默认为5")
    use_integral_num: Optional[int] = Field(None, ge=0, description="高频题消耗积分个数")
    franction: Optional[str] = Field(None, description="每个题型有多少每题多少分")
    paper_time: Optional[int] = Field(None, ge=0, description="考试时长单位(分)")
    reward_integral: Optional[int] = Field(None, ge=0, description="答对一题奖励积分数量")
    medal: Optional[str] = Field(None, description="勋章设置")
    share_integral: Optional[int] = Field(None, ge=0, description="每次分享可得积分")
    sms_accessKeyId: Optional[str] = Field(None, max_length=255, description="短信accesskeyid")
    sms_accessKeySecret: Optional[str] = Field(None, max_length=255, description="短信accesskeysecret")
    about: Optional[str] = Field(None, description="关于我们")
    wechat_number: Optional[str] = Field(None, max_length=255, description="商家微信号")
    standard: Optional[int] = Field(5, ge=0, description="每日答题达标数量")
    pass_: Optional[str] = Field(None, max_length=255, description="通过条件")
    good: Optional[str] = Field(None, max_length=255, description="良好条件")
    excellent: Optional[str] = Field(None, max_length=255, description="优秀条件")
    randoms: Optional[str] = Field(None, max_length=255, description="随机条件")
    randoms_icon: Optional[str] = Field(None, max_length=255, description="随机图标")
    randoms_rule: Optional[str] = Field(None, max_length=255, description="随机规则")
    notdone: Optional[str] = Field(None, max_length=255, description="未完成条件")
    notdone_icon: Optional[str] = Field(None, max_length=255, description="未完成图标")
    notdone_rule: Optional[str] = Field(None, max_length=255, description="未完成规则")
    qhig: Optional[str] = Field(None, max_length=255, description="未知字段（qhig）")
    qhig_icon: Optional[str] = Field(None, max_length=255, description="未知字段（qhig_icon）")
    qhig_rule: Optional[str] = Field(None, max_length=255, description="未知字段（qhig_rule）")
    qint: Optional[str] = Field(None, max_length=255, description="未知字段（qint）")
    qint_icon: Optional[str] = Field(None, max_length=255, description="未知字段（qint_icon）")
    qint_rule: Optional[str] = Field(None, max_length=255, description="未知字段（qint_rule）")
    qhot: Optional[str] = Field(None, max_length=255, description="未知字段（qhot）")
    qhot_icon: Optional[str] = Field(None, max_length=255, description="未知字段（qhot_icon）")
    qhot_rule: Optional[str] = Field(None, max_length=255, description="未知字段（qhot_rule）")
    qdiff: Optional[str] = Field(None, max_length=255, description="未知字段（qdiff）")
    qdiff_icon: Optional[str] = Field(None, max_length=255, description="未知字段（qdiff_icon）")
    qdiff_rule: Optional[str] = Field(None, max_length=255, description="未知字段（qdiff_rule）")
    countdown: Optional[str] = Field(None, max_length=255, description="事件名称")
    countdowntime: Optional[datetime] = Field(None, description="时间点")
    time_display: Optional[int] = Field(1, ge=1, le=2, description="倒计时显示，默认为1")
    student_open: Optional[int] = Field(1, ge=1, le=2, description="学生开启 1开启，默认为1")
    freepoolnum: Optional[int] = Field(0, ge=0, description="题库体验题数，默认为0")
    freeknowledgenum: Optional[int] = Field(0, ge=0, description="知识点体验章数，默认为0")
    info_status: int = Field(1, ge=1, le=2, description="是否必须完善信息1是")
    app_id: str = Field(..., max_length=50, description="微信公众公众号Appid")
    app_secret: str = Field(..., max_length=50, description="微信公众SERECT")
    IOS: int = Field(2, ge=1, le=2, description="1开启 2关闭，默认为2")
    customer_service: str = Field(..., max_length=255, description="客服二维码")

    class Config:
        orm_mode = True


class SettingCreate(SettingBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class SettingUpdate(SettingBase):
    weid: Optional[int] = None
    mchid: Optional[str] = None
    pay_secret: Optional[str] = None
    pay_open: Optional[int] = None
    signcertpath: Optional[str] = None
    signkeypath: Optional[str] = None
    AccessKeyId: Optional[str] = None
    AccessKeySecret: Optional[str] = None
    SignName: Optional[str] = None
    TemplateCode: Optional[str] = None
    RegionId: Optional[str] = None
    banner_height: Optional[int] = None
    shareupper: Optional[int] = None
    share_title: Optional[str] = None
    istatus: Optional[int] = None
    is_display: Optional[int] = None
    display_num: Optional[int] = None
    use_integral_num: Optional[int] = None
    franction: Optional[str] = None
    paper_time: Optional[int] = None
    reward_integral: Optional[int] = None
    medal: Optional[str] = None
    share_integral: Optional[int] = None
    sms_accessKeyId: Optional[str] = None
    sms_accessKeySecret: Optional[str] = None
    about: Optional[str] = None
    wechat_number: Optional[str] = None
    standard: Optional[int] = None
    pass_: Optional[str] = None
    good: Optional[str] = None
    excellent: Optional[str] = None
    randoms: Optional[str] = None
    randoms_icon: Optional[str] = None
    randoms_rule: Optional[str] = None
    notdone: Optional[str] = None
    notdone_icon: Optional[str] = None
    notdone_rule: Optional[str] = None
    qhig: Optional[str] = None
    qhig_icon: Optional[str] = None
    qhig_rule: Optional[str] = None
    qint: Optional[str] = None
    qint_icon: Optional[str] = None
    qint_rule: Optional[str] = None
    qhot: Optional[str] = None
    qhot_icon: Optional[str] = None
    qhot_rule: Optional[str] = None
    qdiff: Optional[str] = None
    qdiff_icon: Optional[str] = None
    qdiff_rule: Optional[str] = None
    countdown: Optional[str] = None
    countdowntime: Optional[datetime] = None
    time_display: Optional[int] = None
    student_open: Optional[int] = None
    freepoolnum: Optional[int] = None
    freeknowledgenum: Optional[int] = None
    info_status: Optional[int] = None
    app_id: Optional[str] = None
    app_secret: Optional[str] = None
    IOS: Optional[int] = None
    customer_service: Optional[str] = None


class SettingInDB(SettingBase):
    id: int

    class Config:
        orm_mode = True


class SettingResponse(SettingInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class SettingListResponse(BaseModel):
    data: List[SettingResponse]


class ShareRecordBase(BaseModel):
    weid: Optional[int] = Field(0, ge=0, description="站点 ID")
    uid: int = Field(..., ge=0, description="用户 ID")
    num: Optional[int] = Field(None, ge=0, description="分享次数")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="是否删除的标识，默认为1")
    day: Optional[date] = Field(None, description="记录哪一天")
    createtime: Optional[int] = Field(None, description="创建时间，Unix 时间戳")

    class Config:
        orm_mode = True


class ShareRecordCreate(ShareRecordBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class ShareRecordUpdate(ShareRecordBase):
    weid: Optional[int] = None
    uid: Optional[int] = None
    num: Optional[int] = None
    istatus: Optional[int] = None
    day: Optional[date] = None
    createtime: Optional[int] = None


class ShareRecordInDB(ShareRecordBase):
    id: int

    class Config:
        orm_mode = True


class ShareRecordResponse(ShareRecordInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class ShareRecordListResponse(BaseModel):
    data: List[ShareRecordResponse]


class SonSimpleBase(BaseModel):
    weid: str = Field(..., max_length=150, description="站点 ID")
    son_title: str = Field(..., max_length=255, description="子标题")

    class Config:
        orm_mode = True


class SonSimpleCreate(SonSimpleBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class SonSimpleUpdate(SonSimpleBase):
    weid: Optional[str] = None
    son_title: Optional[str] = None


class SonSimpleInDB(SonSimpleBase):
    id: int

    class Config:
        orm_mode = True


class SonSimpleResponse(SonSimpleInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class SonSimpleListResponse(BaseModel):
    data: List[SonSimpleResponse]


class TestBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    type: int = Field(..., ge=0, le=255, description="试题类型")
    title: str = Field(..., max_length=255, description="试题题目 仅在列表显示 试卷内不显示")
    libraryid: Optional[int] = Field(0, ge=0, description="题库id")
    question: str = Field(..., description="题目")
    qimage: Optional[str] = Field(None, description="试题图片")
    qaudio: Optional[str] = Field(None, description="问题音频")
    a_type: Optional[int] = Field(0, ge=0, le=255, description="选项类型")
    option: Optional[str] = Field(None, description="选项")
    rightkey: str = Field(..., description="正确答案")
    analysis: str = Field(..., description="答案解析")
    aimage: Optional[str] = Field(None, description="解析图片")
    istatus: Optional[int] = Field(1, ge=1, le=2, description="是否删除的标识，默认为1")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")
    anum: Optional[int] = Field(0, ge=0, description="本题答题次数 仅考试")
    rnum: Optional[int] = Field(0, ge=0, description="正确回答次数 仅考试")
    level: Optional[int] = Field(1, ge=1, le=5, description="难度等级，默认为1")
    qvideo: Optional[str] = Field(None, description="问题视频")
    analysis_audio: Optional[str] = Field(None, description="音频解析")
    knowledge: Optional[str] = Field(None, description="所属知识点类别")
    type_classification: Optional[str] = Field(None, description="类型分类")
    q_year: Optional[str] = Field(None, description="年份")
    pid: Optional[int] = Field(0, ge=0, description="问题父id")
    son_status: Optional[int] = Field(None, description="语音题是否加了小题")
    display: Optional[int] = Field(1, ge=1, le=2, description="1-显示2-不显示，默认为1")
    son_simple: int = Field(0, ge=0, description="子题简化")

    class Config:
        orm_mode = True


class TestCreate(TestBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class TestUpdate(TestBase):
    weid: Optional[int] = None
    type: Optional[int] = None
    title: Optional[str] = None
    libraryid: Optional[int] = None
    question: Optional[str] = None
    qimage: Optional[str] = None
    qaudio: Optional[str] = None
    a_type: Optional[int] = None
    option: Optional[str] = None
    rightkey: Optional[str] = None
    analysis: Optional[str] = None
    aimage: Optional[str] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None
    anum: Optional[int] = None
    rnum: Optional[int] = None
    level: Optional[int] = None
    qvideo: Optional[str] = None
    analysis_audio: Optional[str] = None
    knowledge: Optional[str] = None
    type_classification: Optional[str] = None
    q_year: Optional[str] = None
    pid: Optional[int] = None
    son_status: Optional[int] = None
    display: Optional[int] = None
    son_simple: Optional[int] = None


class TestInDB(TestBase):
    id: int
    createtime: Optional[datetime] = Field(None, description="创建时间")

    @classmethod
    def from_orm(cls, obj):
        if isinstance(obj.createtime, int):
            obj.createtime = datetime.fromtimestamp(obj.createtime)
        return super().from_orm(obj)

    class Config:
        orm_mode = True


class TestResponse(TestInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class TestListResponse(BaseModel):
    data: List[TestResponse]


class TestTypeBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    name: str = Field(..., max_length=255, description="试题库名称")
    pid: Optional[int] = Field(0, ge=0, description="默认0为顶级分类")
    gpid: Optional[int] = Field(0, ge=0, description="默认0")
    price: Optional[Decimal] = Field(Decimal('0.00'), ge=0, description="价格")
    status: Optional[int] = Field(1, ge=0, le=1, description="题库状态，默认为1")
    is_student: Optional[int] = Field(0, ge=0, le=1, description="学员专享 1是，默认为0")
    istatus: Optional[int] = Field(1, ge=0, le=1, description="是否删除的标识，默认为1")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")
    display_order: int = Field(0, description="显示顺序，默认为0")

    class Config:
        orm_mode = True


class TestTypeCreate(TestTypeBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class TestTypeUpdate(TestTypeBase):
    weid: Optional[int] = None
    name: Optional[str] = None
    pid: Optional[int] = None
    gpid: Optional[int] = None
    price: Optional[Decimal] = None
    status: Optional[int] = None
    is_student: Optional[int] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None
    display_order: Optional[int] = None


class TestTypeInDB(TestTypeBase):
    id: int
    createtime: Optional[datetime] = Field(None, description="创建时间")

    @classmethod
    def from_orm(cls, obj):
        if isinstance(obj.createtime, int):
            obj.createtime = datetime.fromtimestamp(obj.createtime)
        return super().from_orm(obj)

    class Config:
        orm_mode = True


class TestTypeResponse(TestTypeInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class TestTypeListResponse(BaseModel):
    data: List[TestTypeResponse]


class TypeCateBase(BaseModel):
    weid: int = Field(..., ge=0, description="站点 ID")
    name: str = Field(..., max_length=255, description="分类名称")
    status: Optional[int] = Field(1, ge=1, le=2, description="状态 1 显示 2不显示，默认为1")
    istatus: Optional[int] = Field(1, ge=0, le=1, description="是否删除的标识，默认为1")
    createtime: int = Field(..., description="创建时间，Unix 时间戳")

    class Config:
        orm_mode = True


class TypeCateCreate(TypeCateBase):
    pass  # 如果创建时需要额外字段或默认值不同，可以在这里添加


class TypeCateUpdate(TypeCateBase):
    weid: Optional[int] = None
    name: Optional[str] = None
    status: Optional[int] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None


class TypeCateInDB(TypeCateBase):
    id: int
    createtime: Optional[datetime] = Field(None, description="创建时间")

    @classmethod
    def from_orm(cls, obj):
        if isinstance(obj.createtime, int):
            obj.createtime = datetime.fromtimestamp(obj.createtime)
        return super().from_orm(obj)

    class Config:
        orm_mode = True


class TypeCateResponse(TypeCateInDB):
    pass  # 可以根据需要添加额外的字段或调整现有字段


# 用于批量操作的模型
class TypeCateListResponse(BaseModel):
    data: List[TypeCateResponse]


from pydantic import BaseModel, Field
from typing import Optional


class WatermarkBase(BaseModel):
    weid: int
    type: int = Field(..., le=2, ge=1, description='1个人信息 2为自定义')
    open: int = Field(default=2, le=2, ge=1, description='1打开水印 2关闭水印')
    content: str = Field(..., max_length=1024, description='水印内容')
    size: int
    rotate: int
    transparent: int
    local_type: int = Field(..., le=2, ge=1, description='1预设 2为自定义 生效位置类型')
    presupposition: int
    horizontal: int
    vertical: int

    class Config:
        orm_mode = True


class WatermarkCreate(WatermarkBase):
    pass


class WatermarkUpdate(WatermarkBase):
    weid: Optional[int] = None
    type: Optional[int] = None
    open: Optional[int] = None
    content: Optional[str] = None
    size: Optional[int] = None
    rotate: Optional[int] = None
    transparent: Optional[int] = None
    local_type: Optional[int] = None
    presupposition: Optional[int] = None
    horizontal: Optional[int] = None
    vertical: Optional[int] = None


class WatermarkInDB(WatermarkBase):
    id: int

    class Config:
        orm_mode = True


class WatermarkResponse(WatermarkInDB):
    pass


class WatermarkListResponse(BaseModel):
    data: List[WatermarkResponse]


class WxTplBase(BaseModel):
    weid: int
    type: int
    tplid: str = Field(..., max_length=255)
    keyword1: Optional[str] = Field(None, max_length=255)
    keyword2: Optional[str] = Field(None, max_length=255)
    keyword3: Optional[str] = Field(None, max_length=255)
    istatus: Optional[int] = Field(default=1, le=1, ge=1, description='删除状态')
    createtime: int

    class Config:
        orm_mode = True


class WxTplCreate(WxTplBase):
    pass


class WxTplUpdate(WxTplBase):
    weid: Optional[int] = None
    type: Optional[int] = None
    tplid: Optional[str] = None
    keyword1: Optional[str] = None
    keyword2: Optional[str] = None
    keyword3: Optional[str] = None
    istatus: Optional[int] = None
    createtime: Optional[int] = None


class WxTplInDB(WxTplBase):
    id: int

    class Config:
        orm_mode = True


class WxTplResponse(WxTplInDB):
    pass


class WxTplListResponse(BaseModel):
    data: List[WxTplResponse]


class XueshengBase(BaseModel):
    weid: int
    uidht: int
    school_id: int
    nianfen_id: int
    banji_id: int
    banjixs_id: int
    xiaozu_id: int
    xiaozuxs_id: int
    sflx: int
    bjcsjf: float = Field(default=0.00)
    bjzf: float = Field(default=0.00)
    displayorder: int
    student_name: Optional[str] = Field(None, max_length=20)
    pic: str = Field(...)
    sex: str = Field(...)
    jiguan: str = Field(...)
    minzu: str = Field(...)
    sfzhm: str = Field(...)
    gxuehao: Optional[str] = Field(None, max_length=25)
    xxuehao: Optional[str] = Field(None, max_length=25)
    zxxuehao: Optional[str] = Field(None, max_length=25)
    student_img: Optional[str] = Field(None, max_length=60)
    parent_name: Optional[str] = Field(None, max_length=20)
    parent_phone: Optional[str] = Field(None, max_length=20)
    qq: str = Field(...)
    phone: str = Field(...)
    yzm: str = Field(...)
    address: Optional[str] = Field(None, max_length=255)
    updatetime: int
    beizhu: str = Field(...)
    addtime: int
    uid: Optional[int] = Field(default=0)
    uid1: Optional[int] = Field(default=0)
    uid2: Optional[int] = Field(default=0)
    uid3: Optional[int] = Field(default=0)
    uid4: Optional[int] = Field(default=0)
    uid5: Optional[int] = Field(default=0)
    uid6: Optional[int] = Field(default=0)
    uid7: Optional[int] = Field(default=0)
    uid8: Optional[int] = Field(default=0)
    openid: str = Field(...)
    openid1: str = Field(...)
    openid2: str = Field(...)
    openid3: str = Field(...)
    openid4: str = Field(...)
    openid5: str = Field(...)
    openid6: str = Field(...)
    openid7: str = Field(...)
    openid8: str = Field(...)
    sflx1: int
    sflx2: int
    sflx3: int
    sflx4: int
    sflx5: int
    sflx6: int
    sflx7: int
    sflx8: int
    nid: int
    name: str = Field(..., max_length=50)
    parentid: int
    enabled: int
    icon: str = Field(..., max_length=100)
    description: str = Field(..., max_length=100)
    styleid: int
    linkurl: str = Field(..., max_length=500)
    ishomepage: int
    icontype: int
    css: str = Field(..., max_length=500)

    class Config:
        orm_mode = True


class XueshengCreate(XueshengBase):
    pass


class XueshengUpdate(XueshengBase):
    # All fields are optional for partial updates
    weid: Optional[int] = None
    uidht: Optional[int] = None
    school_id: Optional[int] = None
    nianfen_id: Optional[int] = None
    banji_id: Optional[int] = None
    banjixs_id: Optional[int] = None
    xiaozu_id: Optional[int] = None
    xiaozuxs_id: Optional[int] = None
    sflx: Optional[int] = None
    bjcsjf: Optional[float] = None
    bjzf: Optional[float] = None
    displayorder: Optional[int] = None
    student_name: Optional[str] = None
    pic: Optional[str] = None
    sex: Optional[str] = None
    jiguan: Optional[str] = None
    minzu: Optional[str] = None
    sfzhm: Optional[str] = None
    gxuehao: Optional[str] = None
    xxuehao: Optional[str] = None
    zxxuehao: Optional[str] = None
    student_img: Optional[str] = None
    parent_name: Optional[str] = None
    parent_phone: Optional[str] = None
    qq: Optional[str] = None
    phone: Optional[str] = None
    yzm: Optional[str] = None
    address: Optional[str] = None
    updatetime: Optional[int] = None
    beizhu: Optional[str] = None
    addtime: Optional[int] = None
    uid: Optional[int] = None
    uid1: Optional[int] = None
    uid2: Optional[int] = None
    uid3: Optional[int] = None
    uid4: Optional[int] = None
    uid5: Optional[int] = None
    uid6: Optional[int] = None
    uid7: Optional[int] = None
    uid8: Optional[int] = None
    openid: Optional[str] = None
    openid1: Optional[str] = None
    openid2: Optional[str] = None
    openid3: Optional[str] = None
    openid4: Optional[str] = None
    openid5: Optional[str] = None
    openid6: Optional[str] = None
    openid7: Optional[str] = None
    openid8: Optional[str] = None
    sflx1: Optional[int] = None
    sflx2: Optional[int] = None
    sflx3: Optional[int] = None
    sflx4: Optional[int] = None
    sflx5: Optional[int] = None
    sflx6: Optional[int] = None
    sflx7: Optional[int] = None
    sflx8: Optional[int] = None
    nid: Optional[int] = None
    name: Optional[str] = None
    parentid: Optional[int] = None
    enabled: Optional[int] = None
    icon: Optional[str] = None
    description: Optional[str] = None
    styleid: Optional[int] = None
    linkurl: Optional[str] = None
    ishomepage: Optional[int] = None
    icontype: Optional[int] = None
    css: Optional[str] = None


class XueshengInDB(XueshengBase):
    xuesheng_id: int

    class Config:
        orm_mode = True


class XueshengResponse(XueshengInDB):
    pass


class XueshengListResponse(BaseModel):
    data: List[XueshengResponse]
